package com.bbtShop.api;

import com.bbtShop.aop.Login;
import com.bbtShop.core.model.ApiResponse;
import com.bbtShop.core.model.PaySource;
import com.bbtShop.core.model.ProductSalesTopDto;
import com.bbtShop.service.IndexService;
import com.bbtShop.service.PaySourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : manke
 * @Description
 * @Date: 2020/10/25 21:00
 */
@Api(value = "IndexController", description = "首页控制器")
@RestController
@RequestMapping("/Index")
public class IndexController {

    @Autowired
    private IndexService indexService;

    @ApiOperation(value = "getIndexSales", notes = "获取首页销售数据")
    @GetMapping("/getIndexSales")
    @Login(permission = "Index:getIndexSales")
    public ApiResponse<Map<String,String>> getIndexSales() {
        return ApiResponse.success(indexService.getIndexSales());
    }

    @ApiOperation(value = "getSalesTop", notes = "获取销售榜单")
    @GetMapping("/getSalesTop")
    @Login(permission = "Index:getSalesTop")
    public ApiResponse<List<ProductSalesTopDto>> getSalesTop() {
        return ApiResponse.success(indexService.getSalesTop());
    }

    @ApiOperation(value = "getStatistics", notes = "获取近一周销量统计图")
    @GetMapping("/getStatistics")
    @Login(permission = "Index:getStatistics")
    public ApiResponse<HashMap<String, Object>> getStatistics() {
        return ApiResponse.success(indexService.getStatistics());
    }

    @ApiOperation(value = "getStatisticsByYear", notes = "获取近半年销量统计图")
    @GetMapping("/getStatisticsByYear")
    @Login(permission = "Index:getStatisticsByYear")
    public ApiResponse<HashMap<String, Object>> getStatisticsByYear() {
        return ApiResponse.success(indexService.getStatisticsByYear());
    }
    @ApiOperation(value = "getDayTotal", notes = "获取每日总销量统计图")
    @GetMapping("/getDayTotal")
    @Login(permission = "Index:getDayTotal")
    public ApiResponse<HashMap<String, Object>> getDayTotal() {
        return ApiResponse.success(indexService.getDayTotal());
    }




}
